﻿<!DOCTYPE html> 
<html>
  <head>
    <!--META-->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.75">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">

    <!--CSS-->
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.min.css" />
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.structure.min.css" />
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.theme.min.css" />
    <link rel="stylesheet" href="API/css/mycss.css" />
    <link rel="stylesheet" href="css/mycss.css" />
	
    <!--JS-->
    <script type="text/javascript" src="API/js/jquery.min.js"></script>
    <script type="text/javascript" src="API/js/jquery.mobile.min.js"></script>
    <script type="text/javascript" src="API/js/highcharts.js"></script>
    <script type="text/javascript" src="API/js/modules/exporting.js"></script>
    <!--<script type="text/javascript" src="API/js/jquery.dataTables.min.js"></script>-->
    <script type="text/javascript" src="include/config.js"></script>
    <script type="text/javascript" src="API/js/fonctions.js"></script>
    <script type="text/javascript" src="js/fonctions.js"></script>
	
    <script language="javascript" type="text/javascript">
    checkMaintenance();
    checkAuthentification();
	
    ///////////////////
    //BLOCK VARIABLE GLOBAL
    ///////////////////
    var id_page = 17;
    var user = "";
    var chartG1;
    var chartG2;
    var tabDataUp = new Array();

    ///////////////////
    //BLOCK FONCTIONS EVENEMENTS
    ///////////////////

    //A la construction de la page
    $(document).on('pageinit',function() {
        try {
            // Init commun
            init_commun();

            // Init page
            var html = getHtmlSuiviKO(tabInfoLogin[0][0]);
            $("#main_content").prepend(html).trigger('create');
        } catch (er) {
            log(0, "ERROR(init_boad):" + er.message);
        }
    });	

    //Affichage de la page avant onload
    $(document).on('pageshow',function() {
        try {	
            show_commun();
        }
        catch (er) {
            log(0, "ERROR(show):" + er.message);
        }
    });

    //Fin chargement page
    function OnLoad() {
        try {
            var user = getParamGet("user");

            if(user == null){
                user = tabInfoLogin[0][0];
            }

            afficherBoard(user);

            var p_dateBegin = getParamGet("dateBegin");
            var p_dateEnd = getParamGet("dateEnd");
            var p_dateStatutBegin = getParamGet("dateStatutBegin");
            var p_dateStatutEnd = getParamGet("dateStatutEnd");
            if(p_dateBegin == null){
                    p_dateBegin = "01/01/1970";
            }

            if(p_dateEnd == null){
                    p_dateEnd = "01/01/2070";
            }

            if(p_dateStatutBegin == null){
                    p_dateStatutBegin = "01/01/1970";
            }

            if(p_dateStatutEnd == null){
                    p_dateStatutEnd = "01/01/2070";
            }

            afficherFerme(user, p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);
            afficherDomainePie(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd, user);
            
            afficheTicketsSupDeb(user);
        }
        catch (er) {
            log(0, "ERROR(refreshG):" + er.message);
        }
    }
		
    ///////////////////
    //BLOCK FONCTIONS METIER
    ///////////////////
    function afficheTicketsSupDeb(p_user){
        try {
            strhtml = "<img src=\"API/img/loading.gif\" alt=\"loading\" style=\"vertical-align:middle;\" />";
            $('#divSupDeb').html(strhtml).trigger('create');
            
            var tabInput = { code_user : p_user };
            callBD(domaine+"phpsql/mysql_getTicketsSupDeb.php", "GET", "text", tabInput, "afficheTicketsSupDeb_retour", true);
        }
        catch (er) {
            log(0, "ERROR(afficheTicketsSupDeb):" + er.message);
        }
    }

    function afficherBoard(p_user) {
        try {
            strhtml = "<img src=\"API/img/loading.gif\" alt=\"loading\" style=\"vertical-align:middle;\" />";
            $('#divBannette').html(strhtml).trigger('create');
            var tabInput = { user : p_user };
            callBD(domaine+"phpsql/mysql_getBoard.php", "GET", "text", tabInput, "afficherBoard_retour", true);
        }
        catch (er) {
            log(0, "ERROR(afficherBoard):" + er.message);
        }
    }
    
    function afficherFerme(p_user, p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
        try {
            var reg = new RegExp("[/]", "g");
            var strDateBegin = p_dateBegin.replace(reg, '');
            var strDateEnd = p_dateEnd.replace(reg, '');
            var strDateStatutBegin = p_dateStatutBegin.replace(reg, '');
            var strDateStatutEnd = p_dateStatutEnd.replace(reg, '');

            strhtml = "<img src=\"API/img/loading.gif\" alt=\"loading\" style=\"vertical-align:middle;\" />";
            $('#divProd').html(strhtml).trigger('create');
            
            var tabInput = { statut:'Ferm\351', user:p_user, dateBegin:strDateBegin, dateEnd:strDateEnd, dateStatutBegin:strDateStatutBegin, dateStatutEnd:strDateStatutEnd };
            callBD(domaine+"phpsql/mysql_getProdByDateByStatutUser.php", "GET", "text", tabInput, "afficherFerme_retour", true);
        }
        catch (er) {
            log(0, "ERROR(afficherFerme):" + er.message);
        }
    }
		
    function afficherDomainePie(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd, p_user) {
        try {
            var reg = new RegExp("[/]", "g");
            var strDateBegin = p_dateBegin.replace(reg, '');
            var strDateEnd = p_dateEnd.replace(reg, '');
            var strDateStatutBegin = p_dateStatutBegin.replace(reg, '');
            var strDateStatutEnd = p_dateStatutEnd.replace(reg, '');
            
            strhtml = "<img src=\"API/img/loading.gif\" alt=\"loading\" style=\"vertical-align:middle;\" />";
            $('#divDomainePie').html(strhtml).trigger('create');
            
            var tabInput = { resp:p_user, dateBegin:strDateBegin, dateEnd:strDateEnd, dateStatutBegin:strDateStatutBegin, dateStatutEnd:strDateStatutEnd };
            callBD(domaine+"phpsql/mysql_getDomainePie.php", "GET", "text", tabInput, "afficherDomainePie_retour", true);

            var tab = new Array();
            tab = getTabDomainePie(strDateBegin, strDateEnd, strDateStatutBegin, strDateStatutEnd, p_user);

            affichePieTag(tab);
        }
        catch (er) {
            log(0, "ERROR(afficherDomainePie):" + er.message);
        }
    }
    
    function radioChange(p_obj){
        try {
            var nom = p_obj.name;
            var reg = new RegExp("[_]+", "g");
            var tableau = nom.split(reg);
            var id_toc = tableau[1];
            var revision = tableau[2];
            var valeur = p_obj.value;
            
            var tabInput = { id_toc:id_toc, revision:revision, sn3:valeur,  code_user:auth  };
            callBD(domaine+"phpsql/mysql_setStatutTicketsSupDeb.php", "GET", "text", tabInput, null, true);   
        }
        catch (er) {
            log(0, "ERROR(radioChange):" + er.message);
        }
    }
		
    ///////////////////
    //BLOCK FONCTIONS BD
    ///////////////////
		
    ///////////////////
    //BLOCK FONCTIONS AFFICHAGE
    ///////////////////
    function afficheTicketsSupDeb_retour(p_retour){
        try {
            var strhtml = "";
            
            //[x][0]id_toc_ori 
            //[x][1]id_toc 
            //[x][2]revision 
            //[x][3]responsable 
            //[x][4]date_creation 
            //[x][5]date_statut 
            //[x][6]libelle
            //[x][7]sn3 
            //[x][8]code_user 
            //[x][9]date_creation
            //[x][10]date_modif
            strhtml += "<center>";
            strhtml += "<table id=\"tabLaListe\" data-role=\"table\" data-mode=\"reflow\" class=\"ui-body-d table-stripe ui-responsive\">";
            strhtml += "<thead>";
            strhtml += "<TR class=\"ui-bar-d\">";
            strhtml += "<TH>N&deg;</TH>";
            strhtml += "<TH>Id</TH>";
            strhtml += "<TH>R&eacute;vision</TH>";
            strhtml += "<TH>Responsable</TH>";
            strhtml += "<TH>Libell&eacute;</TH>";
            strhtml += "<TH>P&eacute;rim&egrave;tre SN3</TH>";
            strhtml += "</thead>";
            strhtml += "<tbody>";
            var i = 0;
            for (var indice in p_retour) {
                strhtml += "<TR onMouseOver=\"changeCouleur(this);\" onMouseOut=\"remetCouleur(this);\" >";
                i++;
                strhtml += "<TD>"+i+"</TD>";
                strhtml += "<TD><a target=\"_new\" href=\"http://10.197.68.30:4000/AutoDiseWeb/automate/popupModule.jsp?modType=SIG_SIG&modCode=" + p_retour[indice][0] + "\">" + p_retour[indice][1] + "</a> </TD>";
                strhtml += "<TD>"+p_retour[indice][2]+"</TD>";
                strhtml += "<TD>"+p_retour[indice][3]+"</TD>";
                strhtml += "<TD>"+p_retour[indice][6].substring(0,50);+"</TD>";
                strhtml += "<TD>";
                strhtml += "<fieldset data-role=\"controlgroup\" data-type=\"horizontal\" data-mini=\"true\">";
                var strChecked = "";
                if(p_retour[indice][7] == "1"){
                    strChecked = "checked=\"checked\"";
                }
                strhtml += "<input type=\"radio\" name=\"InputRadio_"+p_retour[indice][1]+"_"+p_retour[indice][2]+"\" id=\"InputRadio_"+p_retour[indice][1]+"_"+p_retour[indice][2]+"_1\" value=\"1\" "+strChecked+" onchange=\"radioChange(this);\" />";
                strhtml += "<label for=\"InputRadio_"+p_retour[indice][1]+"_"+p_retour[indice][2]+"_1\">Oui</label>";
                var strChecked = "";
                if(p_retour[indice][7] == "0"){
                    strChecked = "checked=\"checked\"";
                }
                strhtml += "<input type=\"radio\" name=\"InputRadio_"+p_retour[indice][1]+"_"+p_retour[indice][2]+"\" id=\"InputRadio_"+p_retour[indice][1]+"_"+p_retour[indice][2]+"_0\" value=\"0\" "+strChecked+"  onchange=\"radioChange(this);\"/>";
                strhtml += "<label for=\"InputRadio_"+p_retour[indice][1]+"_"+p_retour[indice][2]+"_0\">Non</label>";
                strhtml += "</fieldset>";
                strhtml += "</TD>";
                strhtml += "</TR>";
            }
            strhtml += "</tbody>";
            strhtml += "</table>";
            strhtml += "</center>";
            
            $('#divSupDeb').html(strhtml).trigger('create');
            
            if(p_retour.length != 0){
                $( "#content_sup_deb" ).trigger( "expand" );
            }
        }
        catch (er) {
            log(0, "ERROR(afficheTicketsSupDeb_retour):" + er.message);
        }
    }
    
    function afficherBoard_retour(p_retour) {
        try {
            var innerHtmlBoard = getHTMLTabBoard(p_retour);

            $("#divBannette").html(innerHtmlBoard).trigger('create');
        }
        catch (er) {
            log(0, "ERROR(afficherBoard_retour):" + er.message);
        }
    }

    function afficherFerme_retour(p_retour) {
        try {
            var tab = p_retour;

            tabDataUp = new Array();

            tabDataMiddle = new Array();
            tabDataDown = new Array();

            for (var indice in tab) {
                jour = tab[indice][1].substring(8, 10);
                mois = String((tab[indice][1].substring(5, 7)) - 1);
                annee = tab[indice][1].substring(0, 4);
                tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][0]));
                tabDataMiddle[tabDataMiddle.length] = tabDataDown;
            }

            tabDataUp[tabDataUp.length] = {
                name: 'Toc ferm\351',
                data: tabDataMiddle
            };

            afficheGraph(tabDataUp);
        }
        catch (er) {
            log(0, "ERROR(afficherFerme_retour):" + er.message);
        }
    }
    
    function afficherDomainePie_retour(p_retour) {
        try {
            var tab = [];
            for (var indice  in p_retour) {
                var elt = { name:p_retour[indice][0], y:parseInt(p_retour[indice][1])};
                tab[tab.length] = elt;
            }
            
            affichePieTag(tab);
        }
        catch (er) {
            log(0, "ERROR(afficherDomainePie_retour):" + er.message);
        }
    }

    function getHTMLTabBoard(tabBoard) {
        try {
            var strRetour = "";

            strRetour += "<center>";
            strRetour += "<table id=\"tabBannet\" data-role=\"table\" data-mode=\"reflow\" class=\"ui-body-d ui-responsive\" style=\"font-size:14px;text-shadow: none;\">";
            strRetour += "<TR class=\"ui-bar-d\">";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Nom ticket\">Nom ticket</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Statut\">Statut</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Date cr&eacute;ation\">Date cr&eacute;ation</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Date statut\">Date statut</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Priorit&eacute;\">Priorit&eacute;</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Libell&eacute;\">Libell&eacute;</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Dur&eacute;e &eacute;coul&eacute; en minute r&eacute;el\">Dur&eacute;e r&eacute;el</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Temps restant en minute avant fin du SLA\">Dur&eacute;e restant</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Date d'expiration\">Expire</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"R&eacute;vision retour\">R&eacute;vision retour</a></TH>";
            strRetour += "<TH style=\"text-align:center;\"><a href=\"#\" title=\"Date du dernier retour\">Date retour</a></TH>";
            strRetour += "</TR>";

            for (var indice in tabBoard) {
                switch (tabBoard[indice][2]) {
                    case "Support/D\351blocage":
                        strBgColor = "c0c0c0";
                        break;
                    case "Correction":
                        strBgColor = "e0e0e0";
                        break;
                    default:
                        strBgColor = "ffffff";
                        break;
                }

                if ((strBgColor == "ffffff")&(tabBoard[indice][11] < 0)) {
                    strBgColor = "c08080";
                }

                strRetour += "<TR onMouseOver=\"changeOutline(this,'solid','#FF0000');\" onMouseOut=\"changeOutline(this,'hidden','transparent');\">";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;<a target=\"_new\" href=\"http://10.197.68.30:4000/AutoDiseWeb/automate/popupModule.jsp?modType=SIG_SIG&modCode=" + tabBoard[indice][0] + "\">" + tabBoard[indice][1] + "</a> </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][2] + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][3] + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][4] + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][7] + " </TD>";
                strRetour += "<TD style=\"width: 300px;\" bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][8] + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + strMinInHeureMin(tabBoard[indice][10]) + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + strMinInHeureMin(tabBoard[indice][11]) + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + getDateExpire(null, null, null, tabBoard[indice][11]) + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][5] + " </TD>";
                strRetour += "<TD bgcolor=\"" + strBgColor + "\">&nbsp;" + tabBoard[indice][6] + " </TD>";
                strRetour += "</TR>";
            }

            strRetour += "</table>";
            strRetour += "</center>";

            return strRetour;
        }
        catch (er) {
            log(0, "ERROR(getHTMLTabBoard):" + er.message);
        }
    }

    function afficheGraph(tabDataUp) {
    try {
            $('#divProd').highcharts({
                exporting: {
                    url: 'http://export.highcharts.com',
                    filename: 'production_utilisateur',
                    width: 1600
                },
                chart: {
                    type: 'spline'
                },
                title: {
                    text: 'Votre production'
                },
                subtitle: {
                    text: 'By FRO'
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: { // don't display the dummy year
                            month: '%e. %b',
                            year: '%b'
                    }
                },
                yAxis: {
                    title: {
                            text: 'TOC (u)'
                    },
                    min: 0
                },
                tooltip: {
                    formatter: function() {
                            return '<b>' + this.series.name + '</b><br/>' + Highcharts.dateFormat('%e. %b', this.x) + ': ' + this.y + ' toc(s)';
                    }
                },
                series: tabDataUp
        });
    }catch (er) {
            log(0, "ERROR(afficheGraph):" + er.message);
        }
    }
		
    function affichePieTag(p_data) {
        try {
            $('#divDomainePie').highcharts({
                exporting: {
                    url: 'http://export.highcharts.com',
                    filename: 'production_repartie_domaine_utilisateur',
                    width: 1600
                 },
                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false
                },
                title: {
                    text: 'R\351partition des domaines'
                },
                tooltip: {
                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            connectorColor: '#000000',
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'Participation',
                    data: p_data
                }]
            });
            }
            catch (er) {
                    log(0, "ERROR(afficheGraph):" + er);
            }
        }
    	</script>
    
  </head>
  <body onload="OnLoad();">
    
	<!-- page -->
	<div data-role="page" data-title="Titre">
	
		<!-- /panel -->
		<div data-role="panel" id="mypanel" data-display="overlay" data-position="left">

		</div>
		<!-- /panel -->
	
		<!-- header -->
		<div data-role="header" data-position="fixed">
			<a href="#mypanel" data-role="button" data-icon="home" data-iconpos="notext">home</a>
			<h1 id="id_titre">titre</h1>
			<a href="javascript:window.location = ('./page_contact.html?mili='+getMilise());" data-role="button" data-icon="info" data-iconpos="notext">Contact</a>
		</div>
		<!-- /header -->

		<!-- content -->
		<div data-role="content" id="main_content">
		
			<div data-role="collapsible" data-collapsed="false" data-mini="true">
				<h3>Votre Banette</h3>
				<div id="divBannette">Anomalie code E002</div>
			</div>
                    
                        <div data-role="collapsible" data-collapsed="true" data-mini="true" id="content_sup_deb">
				<h3>Vos tickets en Support/D&eacute;blocage</h3>
				<div id="divSupDeb">Anomalie code E002</div>
			</div>
			
			<div data-role="collapsible" data-collapsed="false" data-mini="true">
				<h3>Votre production</h3>
				<div id="divProd">Anomalie code E003</div>
			</div>
			
			<div data-role="collapsible" data-collapsed="false" data-mini="true">
				<h3>La r&eacute;partition</h3>
				<div id="divDomainePie">Anomalie code E004</div>
			</div>				
			
		</div>
		<!-- /content -->
		
		<!-- footer -->
		<div data-role="footer" data-position="fixed">
			<a data-role="button" data-icon="search" data-iconpos="notext" class="ui-btn-left" href="javascript:window.location = ('./page_faq.html?mili='+getMilise());">FAQ</a>
			<h1 id="id_affichageUser">User</h1>
			<a data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right" href="javascript:window.location = ('./page_sortie.html?mili='+getMilise());">Logout</a>
		</div>
		<!-- /footer -->
		
	</div>
	<!-- /page -->
</body>
</html>